﻿using National.Bll.IService;
using National.Bll.Service;
using National.Model;
using National.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
/// <summary>
/// 会员管理
/// </summary>
namespace National.Controllers
{
    public class MemberController : Controller
    {
        #region .
        // 会员管理控制器
        //private IMember member;
        //public MemberController(IMember Imember)
        //{
        //    member = Imember;
        //}
        #endregion
        Member member = new Member();
        /// <summary>
        /// 显示表格信息
        /// </summary>
        /// <param name="page"></param>
        /// <param name="limit"></param>
        /// <returns></returns>
        public JsonResult Display(int page, int limit, string LoginName, string Time)
        {
            List<User> admins = member.Display(LoginName, Time);
            PageListResult<User> a = new PageListResult<User>();
            a.count = admins.Count;
            a.code = 0;
            a.msg = "";
            a.data = admins.Skip((page - 1) * limit).Take(limit).ToList(); ;
            return Json(a, JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public JsonResult Delete(int ID)
        {
            User user = new User();
            user.Id = ID;
            Operate op = new Operate();
            op.Success = member.Delete(user);
            return Json(op);
        }

        public JsonResult Enable(int ID,int status)
        {
            User user = new User();
            user.Id = ID;
            user.Status = status;
            Operate op = new Operate();
            op.Success = member.Enable(user);
            return Json(op);
        }

        public JsonResult UpdateUser(User user)
        {
            Operate op = new Operate();
            op.Success = member.UpdateUser(user);
            return Json(op);
        }
    }
}